import difflib

test1 = "hello world \n" \
        "hello zhangsan \n" \
        "hello zhangyuping\n" \
        "hello python \n"
test2 = "hello world \n" \
        "hello zhangsan \n" \
        "hello java \n"
text1 = test1.splitlines()
text2 = test2.splitlines()

d = difflib.Differ()
diff = d.compare(text1, text2)
print('\n'.join(list(diff)))

d = difflib.HtmlDiff()
print (d.make_file(text1,text2))
